package com.hl.qzzpbackend.model.enums;

import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

/**
 * 工作天数类型枚举
 *
 * @author helong
 */
@Getter
public enum WorkDaysEnum {
    DOUBLE_DAY_OFF("双休",0),
    SINGLE_DAY_OFF("单休",2),
    ALTERNATING_WEEK("大小周",1),
    NO_DAYS_OFF("无休制",3);

    private final String text;

    private final Integer value;

    WorkDaysEnum(String text, Integer value) {
        this.text = text;
        this.value = value;
    }


    /**
     * 根据value获取枚举
     * @param value 枚举值的value
     * @return 枚举值
     */
    public static WorkDaysEnum getEnumByValue(Integer value) {
        if(ObjUtil.isEmpty(value)) {
            return null;
        }
        for (WorkDaysEnum workDaysEnum : WorkDaysEnum.values()) {
            if (workDaysEnum.getValue().equals(value)) {
                return workDaysEnum;
            }
        }
        return null;
    }
}
